#!/bin/bash

source /mnt/rootfs/scripts/common.vars

exec 2>/dev/console
exec 1>/dev/console

clear
/mnt/rootfs/scripts/splash.sh
sleep 3
clear

echo
echo
echo
echo "        #######################################################################"
echo "        ##                                                                   ##"
echo "        ##                   Welcome to atvMod.com $VERSION                       ##"
echo "        ##                                                                   ##"
echo "        #######################################################################"
echo
sleep 1

#Pre Install Stuff
mkdir /mnt/OSBoot
fsck.hfsplus -f /dev/sda3
mount -t hfsplus -o rw,force /dev/sda3 /mnt/OSBoot
echo " "
echo "        Starting atvMod.com $VERSION Patching Process..."
echo

echo "        Mounting OSBoot...                                                [ok]"

touch /mnt/OSBoot/.readwrite
echo "        Keeping OSBoot readwrite...                                       [ok]"

# Install SSH
if [ -f /mnt/rootfs/stuff/ssh/install.sh ]; then
  /mnt/rootfs/stuff/ssh/install.sh 
  echo "        Installing SSH...                                                 [ok]"
else
  echo "        Installing SSH...                                               [FAIL]"
fi

# Install BootLogo
if [ -f /mnt/rootfs/BootLogo.png ]; then
  mv /mnt/OSBoot/System/Library/CoreServices/BootLogo.png /mnt/OSBoot/System/Library/CoreServices/BootLogo.png.bak
  cp /mnt/rootfs/BootLogo.png /mnt/OSBoot/System/Library/CoreServices/BootLogo.png
  echo "        Installing Boot Logo...                                           [ok]"
else
  echo "        Installing Boot Logo...                                         [FAIL]"
fi

echo
echo "        atvMod.com $VERSION Process is DONE..."

# Post Install Stuff + Splash
sleep 2
sync &>/dev/null
umount /mnt/OSBoot
clear
/mnt/rootfs/scripts/done.sh

sleep 100000
